<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" 
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h2></h2>
<h:form id="frmListaInsumos">
        <p:dataTable id="singleDT" var="unInsumo" 
                     value="#{insumoCtrl.listaInsumo}" selectionMode="single" 
                     selection="#{insumoCtrl.insumo}" rowKey="#{unInsumo.id}">
            <f:facet name="header">
                Insumos para la construccion
            </f:facet>
            <p:column headerText="Id">
                <h:outputText value="#{unInsumo.id}" />
            </p:column>
            <p:column headerText="Fecha y Hora Entrega">
                <h:outputText value="#{unInsumo.descripcion}" />
            </p:column>
            <p:column headerText="Costo">
                <h:outputText value="#{unInsumo.costo}" />
            </p:column>
            <p:column headerText="Stock">
                <h:outputText value="#{unInsumo.stock}" />
            </p:column>
            <p:column headerText="Precio">
                <h:outputText value="#{unInsumo.precio.precioFinal(unInsumo)}" />
            </p:column>
            <f:facet name="footer">
                <p:commandButton process="singleDT" update=":frmAbmInsumo" icon=".ui-icon-pencil" value="Editar" oncomplete="PF('insumoDialog').show()" />
                <p:commandButton icon="ui-icon-plusthick" value="Nuevo" oncomplete="PF('insumoDialog').show()" actionListener="#{insumoCtrl.nuevo()}"/>
            </f:facet>
        </p:dataTable>
    
</h:form>
    <h:form id="frmAbmInsumo">
                <p:dialog header="Orden de Provision" widgetVar="insumoDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="true" width="450">
            <p:panelGrid columns="2" >
                <h:outputText value="Descripcion:" />
                <h:inputText value="#{insumoCtrl.insumo.descripcion}" />
                <h:outputText value="Costo:" />
                <h:inputText value="#{insumoCtrl.insumo.costo}" >
                    <f:convertNumber pattern="#0.000"  currencySymbol="$" type="currency" />
                </h:inputText>
                <h:outputText value="Stock:" />
                <h:inputText value="#{insumoCtrl.insumo.stock}" >
                    <f:convertNumber type="number" integerOnly="true" />
                </h:inputText>
                <p:commandButton process="frmAbmInsumo" actionListener="#{insumoCtrl.guardar()}" icon="ui-icon-disk" value="Guardar" oncomplete="PF('insumoDialog').hide()" update=":frmListaInsumos"/>

            </p:panelGrid>
        </p:dialog>

    </h:form>
</ui:composition>


